Skip to content

refactor: migrate Xtend to Java - com.avaloq.tools.ddk.xtext.generator (parser group)#1429

Open
joaodinissf wants to merge 2 commits into
dsldevkit:masterfrom
joaodinissf:migrate/xtend-to-java/xtext-generator-parser
Open

refactor: migrate Xtend to Java - com.avaloq.tools.ddk.xtext.generator (parser group)#1429
joaodinissf wants to merge 2 commits into
dsldevkit:masterfrom
joaodinissf:migrate/xtend-to-java/xtext-generator-parser

Conversation

@joaodinissf

Copy link
Copy Markdown
Collaborator

Migrates the parser group of com.avaloq.tools.ddk.xtext.generator (parser/antlr + parser/common, 6 files) from Xtend to hand-written Java:
AbstractAnnotationAwareAntlrGrammarGenerator, AnnotationAwareAntlrContentAssistGrammarGenerator, AnnotationAwareAntlrGrammarGenerator, AnnotationAwareXtextAntlrGeneratorFragment2, GrammarRuleAnnotations, PredicatesNaming.

Notes

  • The ANTLR StringConcatenation code-generation templates were byte-verified against the xtend-gen ground truth.
  • Local gate green: clean verify checkstyle:check pmd:check pmd:cpd-check spotbugs:check (0 violations).
  • Split module: this is one half of xtext.generator; the per-module Xtend build infra (xtend-gen wiring, MANIFEST, build.properties/.classpath/.project) is intentionally left untouched — it will be cleaned once both the parser and the builder PRs merge (12 sibling .xtend remain).

Blind adversarial review verdict: SHIP (only 2 invented-Javadoc nits).

…r (parser group)

Migrate parser group (6 files) to hand-written Java; ANTLR StringConcatenation templates byte-verified vs xtend-gen; local gate green.

Split of com.avaloq.tools.ddk.xtext.generator: per-module Xtend infra cleanup deferred until both parser+builder PRs merge.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
joaodinissf added a commit to joaodinissf/dsl-devkit that referenced this pull request Jun 17, 2026
…r (builder group)

Migrates 12 generator fragment/support classes from Xtend to Java: BundleVersionStripperFragment, DefaultFragmentWithOverride, builder/BuilderIntegrationFragment2, builder/LspBuilderIntegrationFragment2, builder/StandaloneBuilderIntegrationFragment2, formatting/FormatterFragment2, languageconstants/LanguageConstantsFragment2, model/project/ProjectConfig, modelinference/ModelInferenceFragment2, resourceFactory/ResourceFactoryFragment2, ui/compare/CompareFragment2, and ui/contentAssist/AnnotationAwareContentAssistFragment2. Xtend rich-string templates were rewritten as explicit StringConcatenation/string building, implicit getters/extension methods made explicit, and null-safe operators expanded to guarded Java. Behaviour is preserved; only language form changes. This is the builder half of the com.avaloq.tools.ddk.xtext.generator split (parser half tracked in dsldevkit#1429); per-module Xtend infrastructure cleanup is deferred until both halves merge.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@joaodinissf joaodinissf marked this pull request as ready for review June 17, 2026 16:25
@joaodinissf joaodinissf requested a review from rubenporras June 17, 2026 16:25

@rubenporras rubenporras left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: I have seen that Claude constantly forgets that he should try to use multi-line strings for readability. I use to interject it as steering once the skill has been kicked in, and that has worked fine so far.


protected CharSequence compileLexerMembers(final Grammar it, final AntlrOptions options) {
final StringConcatenation builder = new StringConcatenation();
builder.append("@members {");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is clearly a multi line string.

protected CharSequence compileLexer(final Grammar it, final AntlrOptions options) {
final StringConcatenation builder = new StringConcatenation();
builder.append(codeConfig.getFileHeader());
builder.newLineIfNotEmpty();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a builder is justified for this case, but it would be better to remove the usage of org.eclipse.xtend2.lib.StringConcatenation, do you agree?


@Override
protected String compileParserImports(final Grammar it, final AntlrOptions options) {
final StringConcatenation builder = new StringConcatenation();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is clearly a multi line string.


protected CharSequence compileParserSetTokenStreamMethod() {
final StringConcatenation builder = new StringConcatenation();
builder.append("/**");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is clearly a multi line string, and so on, I did not continue the review.

Address review feedback (dsldevkit#1429): convert the static and single-statement
interpolated grammar-fragment templates to Java text blocks with .formatted()
- compileLexerMembers, compileParserImports, compileParserMemberDeclarations,
compileParserSetTokenStreamMethod, compileRuleCatch.

Builders that compose sub-results via newLineIfNotEmpty (compileLexer), use the
two-argument append(value, indent) re-indentation, or contain FOR/IF control
flow are left as StringConcatenation, per the skill's "StringBuilder for control
flow only" rule - so the org.eclipse.xtend2.lib.StringConcatenation import stays.

Separate commit on top of the migration; output proven byte-identical to the
prior code for every converted method (verified against the real
StringConcatenation runtime).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants